package cn.iocoder.yudao.module.shop.staff.pojo.po;

import cn.iocoder.yudao.framework.business.basic.pojo.po.MerchantScopeEntity;
import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler;
import cn.iocoder.yudao.framework.validation.InEnumValue;
import cn.iocoder.yudao.module.api.shop.staff.enums.ShopStaffRoleEnum;
import cn.iocoder.yudao.module.api.shop.staff.enums.ShopStaffStatusEnum;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 店铺员工 DO
 *
 * @author 山野羡民
 */
@TableName(value = "shop_staff", autoResultMap = true)
@KeySequence("shop_staff_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库，可不写。
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ShopStaff extends MerchantScopeEntity {
    @Schema(description = "角色：0-普通店员、1-店长、2-核销员、3-配送员、4-收银员、5-业务员")
    @InEnumValue(ShopStaffRoleEnum.class)
    @TableField(typeHandler = IntegerListTypeHandler.class)
    private List<Integer> roles;

    public List<Integer> getRoles() {
        if (roles == null) {
            roles = List.of(ShopStaffRoleEnum.NORMAL.getValue());
        }
        return roles;
    }

    @Schema(description = "类型：0-空闲、1-忙碌、2-休息")
    @InEnumValue(ShopStaffStatusEnum.class)
    private Integer status;

    @Schema(description = "姓名")
    private String contactName;

    @Schema(description = "电话")
    private String contactMobile;

    @Schema(description = "前台用户编号")
    private Long memberUserId;

    @Schema(description = "后台用户编号")
    private Long adminUserId;

    @Schema(description = "最后一次送达时间")
    private LocalDateTime lastArrivedTime;

}